//============================================================================
// Name        : string-compare.cpp
// Author      : Krzysztof Spisak-Spisacki
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <time.h>
#include <stdio.h>

#include "TunedBoyerMoore.h"
#include "K2SComparator.h"
#include "Utils/FileUtils.h"

using namespace std;

int main()
{
	cout << "starting\n";

	K2SComparator* comp = new K2SComparator(new TunedBoyerMoore());

	string source = FileUtils::readStringFromFile("TestFiles/oop1.txt");
	string target = FileUtils::readStringFromFile("TestFiles/oop2.txt");

	comp->execute(source, target);

	CompareMetricSource* sourceMetrics = comp->getSourceMetrics();
	CompareMetricTarget* targetMetrics = comp->getTargetMetrics();

	map<string, int> sourceWordsCount = sourceMetrics->getWordsCount();
	map<string, int> targetWordsCount = targetMetrics->getWordsCount();

//	cout << "Source: " << endl;
//	cout << source << endl << endl;
//
//
//	cout << "Target: " << endl;
//	cout << target << endl << endl;

//	cout << "Source words count:\n\n";
//
//	for (map<string, int>::iterator iter = sourceWordsCount.begin(); iter != sourceWordsCount.end(); iter++)
//	{
//		if (iter->second > 10)
//		{
//			cout << iter->first << "\t\t\t" << iter->second << endl;
//		}
//	}
//
//	cout << "Target words count:\n\n";
//
//	for (map<string, int>::iterator iter = targetWordsCount.begin(); iter != targetWordsCount.end(); ++iter)
//	{
//		if (iter->second > 10)
//		{
//			cout << iter->first << "\t\t\t" << iter->second << endl;
//		}
//	}

//	cout << "Source text:" << endl;
//	cout << target << endl << endl;
//
//	sourceMetrics->generateNWords(5);
//	targetMetrics->generateNWords(5);
//
//	map<int, vector<string> > nWords = targetMetrics->getNWords();
//
//	map<int, vector<string> >::iterator it = nWords.begin();
//
//	cout << "Source word sequences 2 long:" << endl;
//
//	for (int i = 0; i < it->second.size(); i++)
//	{
//		cout << it->second[i] << endl;
//	}
//
//	it++;
//
//	cout << "Source word sequences 3 long:" << endl;
//
//	for (int i = 0; i < it->second.size(); i++)
//	{
//		cout << it->second[i] << endl;
//	}

	cout << "Matches:" << endl;

	int start = clock();

	vector<string> matches = comp->findExactMatches(4, 6);

	int end = clock();

	for (int i = 0; i < matches.size(); i++)
	{
		cout << matches[i] << endl;
	}

	printf("dlugosc tekstow: %d, %d\n", source.size(), target.size());
	printf("%d ms\n", end - start);

	cout << endl << endl << "finished";

	return 0;
}
